﻿<UserControl xmlns:ParseControls="clr-namespace:ParseControls;assembly=ParseControls"  x:Class="ParseOnlineAdmin.ParseRelatedComments"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:ParseOnlineAdmin"
             mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>

        <local:ParseObjectToStringConverter x:Key="valueConverter" />

        <SolidColorBrush x:Key="transp" Color="Transparent"  Opacity="0" />
        <SolidColorBrush x:Key="snow" Color="Transparent" Opacity="0.0001" />
        <SolidColorBrush  x:Key="min"  Color="White" Opacity="0.05" />
        <SolidColorBrush  x:Key="light"  Color="White" Opacity="0.1" />
        <SolidColorBrush x:Key="over" Color="White"  Opacity="0.2" />
        <SolidColorBrush x:Key="selected"  Color="White"  Opacity="0.3" />

        <!-- FocusVisual -->
        <Style x:Key="SimpleFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border
                        BorderBrush="Transparent"
                        BorderThickness="0"
                        SnapsToDevicePixels="true">
                            <!--
                            <Border.Effect>
                            <DropShadowEffect ShadowDepth="0"
                            Color="Gray"
                            BlurRadius="5" />
                            </Border.Effect>
                        -->
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="listboxitem" TargetType="ListBoxItem">
            <Setter Property="Opacity" Value="0" />
            <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TranslateTransform Y="-10" />
                </Setter.Value>
            </Setter>
            <Setter  Property="FocusVisualStyle" Value="{StaticResource SimpleFocusVisual}" />
            <Setter Property="BorderBrush" Value="#fff" />
            <Setter Property="BorderThickness" Value="0,0,0,1" />
            <Setter Property="Foreground" Value="#fff" />
            <Setter Property="Background" Value="#333" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Background="{TemplateBinding Background}"
                                    SnapsToDevicePixels="true">
                            
                            <Rectangle x:Name="rectBg" SnapsToDevicePixels="true" />
                            

                            <ContentPresenter Margin="0" HorizontalAlignment="Stretch"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                SnapsToDevicePixels="true" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="Loaded">
                                <BeginStoryboard>
                                    <Storyboard Storyboard.DesiredFrameRate="30">
                                        <DoubleAnimation AccelerationRatio="0.3" DecelerationRatio="0.7"
                                        Duration="0:0:0.7" From="0"
                                        Storyboard.TargetProperty="Opacity" To="1" />
                                        <DoubleAnimation AccelerationRatio="0.3" DecelerationRatio="0.7"
                                        Duration="0:0:0.7" From="-10"
                                        Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)"
                                        To="0" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Fill" TargetName="rectBg" Value="{StaticResource min}" />
                                <Setter Property="TextBlock.Foreground" Value="#fff" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="False" />
                                    <Condition Property="IsMouseOver" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Fill" TargetName="rectBg" Value="{StaticResource light}" />
                                <Setter Property="TextBlock.Foreground" Value="#fff" />
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="True" />
                                    <Condition Property="IsMouseOver" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Fill" TargetName="rectBg" Value="{StaticResource over}" />
                                <Setter Property="TextBlock.Foreground" Value="#fff" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Background" Value="Silver" />
                    <Setter Property="Foreground" Value="White" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="listbox" TargetType="{x:Type ListBox}">
            <Setter  Property="BorderThickness"  Value="0" />
            <Setter  Property="Margin"  Value="0" />
            <Setter  Property="Padding"  Value="0" />
            <Setter Property="Background"  Value="{StaticResource snow}" />
        </Style>
        <Style x:Key="textbox" TargetType="{x:Type TextBox}">
            <Setter Property="Background" Value="{StaticResource light}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Padding" Value="3" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Background" Value="{StaticResource over}" />
                    <Setter  Property="BorderThickness"  Value="0" />
                </Trigger>
                <Trigger  Property="IsFocused" Value="true">
                    <Setter  Property="Background" Value="{StaticResource selected}" />
                    <Setter  Property="BorderThickness" Value="0" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>


    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!--<TextBlock Text="Kommentare" FontWeight="Bold" Margin="5" Grid.Row="0" />-->

        <ParseControls:FwTextBox x:Name="txtComment" BackgroundText="hinzufuegen..." 
                                 KeyUp="TextBox_KeyUp" Margin="5" Grid.Row="1" />
        
        <ListBox Margin="5"  Grid.Row="2" ItemContainerStyle="{StaticResource listboxitem}"
                     Style="{StaticResource listbox}"
                        ItemsSource="{Binding Path=RelatedCommentItems, Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}"
                                    ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                    ScrollViewer.VerticalScrollBarVisibility="Auto"
                                    SelectedItem="{Binding Path=SelectedRelatedComment, Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid  Margin="2">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>


                        <TextBlock     Grid.Column="0"   Grid.Row="0"
                                                    Margin="3,1"
                                                    FontWeight="Bold"
                         
                                                    Text="{Binding Converter={StaticResource valueConverter}, ConverterParameter=Title}" />
                        <!--<TextBlock Grid.Column="1"  Grid.Row="0"
                               Margin="3,1" Foreground="#777" TextAlignment="Right"
                                      Text="{Binding Path=ClassName}"
                                                    TextTrimming="CharacterEllipsis" />-->

                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        
    </Grid>
 
</UserControl>
